//
//  ParentViewController.m
//  Scanner
//
//  Created by 米明 on 15/5/14.
//  Copyright (c) 2015年 米明. All rights reserved.
//

#import "ParentViewController.h"

@interface ParentViewController ()

@end

@implementation ParentViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.automaticallyAdjustsScrollViewInsets=YES;
    self.edgesForExtendedLayout=UIRectEdgeNone;
    // Do any additional setup after loading the view.
}
-(void)showInfo:(NSString * )info{
    [[self infoLabel] setHidden:NO];
    [[self infoLabel] setText:info];
    [UIView animateWithDuration:2.0 animations:^{
        _label.alpha=0;
    } completion:^(BOOL finished) {
        if (finished) {
            [_label removeFromSuperview];
            _label = nil;
        }
    }];
}
-(UILabel *)infoLabel{
    if (!_label) {
        _label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 80, 40)];
        _label.center=CGPointMake(ScreenSize.width/2.0, ScreenSize.height/3.0);
        _label.backgroundColor=[UIColor colorWithWhite:0 alpha:0.68];
        _label.textColor=[UIColor whiteColor];
        _label.layer.masksToBounds=YES;
        _label.layer.cornerRadius=4;
        _label.textAlignment=NSTextAlignmentCenter;
        _label.font = [UIFont systemFontOfSize:16];
        _label.hidden=YES;
        [self.view addSubview:_label];
    }
    return _label;
}
#pragma mark - 通用警告框

-(void)showAlertViewTitle:(NSString *)title message:(NSString *)message cancelButton:(NSString *)cancleTitle otherButtonTitle:(NSString *)otherTitle{
    _alertView=[[UIAlertView alloc]initWithTitle:title message:message delegate:self cancelButtonTitle:cancleTitle otherButtonTitles:otherTitle,nil];
    [_alertView show];
    
}

-(void)creatLeftBtnItemWithTitle:(NSString *)title{
    
    if (self.navigationItem.leftBarButtonItem!=nil) {
        self.navigationItem.leftBarButtonItem=nil;
    }
    
    UIBarButtonItem * left=[[UIBarButtonItem alloc]initWithTitle:title style:UIBarButtonItemStylePlain target:self action:@selector(leftBarBtnItem)];
    self.navigationItem.leftBarButtonItem=left;
    
}
-(void)leftBarBtnItem{
    //左按钮
}

-(void)creatRightBtnItemWithTitle:(NSString *)title{
    
    if (self.navigationItem.rightBarButtonItem!=nil) {
        self.navigationItem.rightBarButtonItem=nil;
    }
    UIBarButtonItem * right=[[UIBarButtonItem alloc]initWithTitle:title style:UIBarButtonItemStylePlain target:self action:@selector(rightBarBtnItem)];
    
    self.navigationItem.rightBarButtonItem=right;
    
    
}
-(void)rightBarBtnItem{
    //右按钮
}

-(void)creatLeftBtnItemWithImageName:(NSString *)imageName{
    if (self.navigationItem.leftBarButtonItem!=nil) {
        self.navigationItem.leftBarButtonItem=nil;
    }
    UIBarButtonItem * left=[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:imageName] style:UIBarButtonItemStylePlain target:self action:@selector(leftBarBtnItem)];
    self.navigationItem.leftBarButtonItem=left;
    
}


-(void)creatRightBtnItemWithImageName:(NSString *)imageName{
    if (self.navigationItem.rightBarButtonItem!=nil) {
        self.navigationItem.rightBarButtonItem=nil;
    }
    UIBarButtonItem * right=[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:imageName] style:UIBarButtonItemStylePlain target:self action:@selector(rightBarBtnItem)];
    self.navigationItem.rightBarButtonItem=right;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
